using System;

abstract class Shape
{
    public abstract double GetArea();
    public abstract double GetPerimeter();
    public override string ToString() => $"Area: {GetArea()}, Perimeter: {GetPerimeter()}";
}

class Circle : Shape
{
    private double radius;
    public Circle(double radius) => this.radius = radius;
    public override double GetArea() => Math.PI * radius * radius;
    public override double GetPerimeter() => 2 * Math.PI * radius;
}

class Rectangle : Shape
{
    private double width, height;
    public Rectangle(double width, double height)
    {
        this.width = width;
        this.height = height;
    }
    public override double GetArea() => width * height;
    public override double GetPerimeter() => 2 * (width + height);
}

class Triangle : Shape
{
    private double a, b, c;
    public Triangle(double a, double b, double c)
    {
        if (a + b <= c || a + c <= b || b + c <= a)
            throw new ArgumentException("Invalid triangle sides");
        this.a = a;
        this.b = b;
        this.c = c;
    }
    public override double GetArea()
    {
        double s = (a + b + c) / 2;
        return Math.Sqrt(s * (s - a) * (s - b) * (s - c));
    }
    public override double GetPerimeter() => a + b + c;
}

class Program
{
    static void Main()
    {
        Console.WriteLine("Enter shape (circle, rectangle, triangle):");
        string type = Console.ReadLine().ToLower();
        Shape shape = type switch
        {
            "circle" => new Circle(Convert.ToDouble(Console.ReadLine())),
            "rectangle" => new Rectangle(Convert.ToDouble(Console.ReadLine()), Convert.ToDouble(Console.ReadLine())),
            "triangle" => new Triangle(Convert.ToDouble(Console.ReadLine()), Convert.ToDouble(Console.ReadLine()), Convert.ToDouble(Console.ReadLine())),
            _ => throw new NotSupportedException()
        };
        Console.WriteLine(shape);
    }
}
